package com.nitramf.catchmystream.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 * RSS Feed
 * @author martinfilliau
 */
@Entity
@NamedQueries({
    @NamedQuery(name=RssFeed.QUERY_GET_ALL_ACTIVATED, query="SELECT r FROM RssFeed AS r WHERE r.isActivated = true")
})
public class RssFeed extends Subscription implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Basic
    private String name;

    @Basic
    @Column(length=1000)
    private String uri;

    @Basic
    private boolean iAmTheAuthor;
    
    @Basic
    private boolean isActivated;

    
    /* Queries */

    /**
     * Get all activated RSS feeds
     */
    public static final String QUERY_GET_ALL_ACTIVATED = "RssFeed.getAllActivated";


    /* GETTERs and SETTERs */

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public boolean isiAmTheAuthor() {
        return iAmTheAuthor;
    }

    public void setiAmTheAuthor(boolean iAmTheAuthor) {
        this.iAmTheAuthor = iAmTheAuthor;
    }

    public boolean isIsActivated() {
        return isActivated;
    }

    public void setIsActivated(boolean isActivated) {
        this.isActivated = isActivated;
    }


    /* Overriden methods */

    @Override
    public int hashCode() {
        int hash = 0;
        hash += ( id != null ? id.hashCode() : 0 );
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!( object instanceof RssFeed )) {
            return false;
        }
        RssFeed other = (RssFeed) object;
        if (( this.id == null && other.id != null ) || ( this.id != null && !this.id.equals(other.id) )) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.nitramf.catchmystream.entities.RssFeed[id=" + id + "]";
    }

}
